﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IsmsExplorer.Model.Projects;
using IsmsExplorer.Infrastructure.EntityFactoryFramework;
using IsmsExplorer.Infrastructure.Helper;

namespace IsmsExplorer.Infrastructure.Repositories {
    internal class ProjectFactory : IEntityFactory<Project> {
        internal static class FieldNames {
            public const string ID = "ID";
            public const string Name = "Name";
            public const string StartDate = "StartDate";
        } // end internal static class FieldNames

        public Project BuildEntity(System.Data.IDataReader reader) {
            return new Project(DataHelper.GetInteger(reader[FieldNames.ID]), reader[FieldNames.Name].ToString()) {
                StartDate = reader.IsDBNull(reader.GetOrdinal(FieldNames.StartDate)) ? null : (DateTime?)reader[FieldNames.StartDate]
            };
        }

    } // end internal class ProjectFactory : IEntityFactory<Project>
}
